<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员工作台</title>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css">
</head>

<body>


    <div class="container" style="margin-top: 30px">
        <div class="row">
            <div class="col-xs-3">
                <ul class="nav nav-pills nav-stacked">
                    <li role="presentation" class="active"><a onclick="skip()">修改密码</a></li>
                    <li role="presentation" data-toggle="modal" data-target="" onclick=""><a href="#">调查问卷相关信息</a></li>
                    <li role="presentation" class="active" data-toggle="modal" data-target="" onclick="warning()"><a
                            href="#">单位管理</a></li>

                    <li role="presentation" class="active" data-toggle="modal" data-target="" onclick="warning()"><a
                            href="#">用户管理</a></li>

                    <li role="presentation" class="active" data-toggle="modal" data-target="" onclick="warning()"><a
                            href="#">日志管理</a></li>


                </ul>
            </div>

            <div class="col-md-9">
                <ul class="list-group" style="height:20rem;width: 80rem;">
                    <a class="list-group-item active"> 问卷调查管理系统 </a>
                    <div class="list-group-item">

                        <h4 class="list-group-item-heading" style="color:black">
                            欢迎{{username}}超级管理员</h4>

                        <a href="#" style="float: right" onclick="logout()">退出系统&nbsp;</a>
                        <h1></h1>


                    </div>
                    <table class="table table-dark">
                        <thead>
                            <tr>
                                <th scope="col">#</th>
                                <th scope="col">主题</th>
                                <th scope="col">创建时间</th>
                                <th scope="col">发起人</th>
                                <th scope="col">问卷操作</th>
                                <th scope="col">问卷操作</th>
                                <td></td>
                                <td></td>
                            </tr>
                        </thead>
                        <tbody>
                            {% for QS in NewQS %}
                            <tr>
                                <th scope="row">{{QS.id}}</th>
                                <td>{{QS.topic}}</td>
                                <td>{{QS.createdTime}}</td>
                                <td>{{QS.publishUserName}}</td>

                                <td> <a onclick="findResult('{{QS.id}}')">查看结果</a></td>
                                <td><a onclick="removeQS('{{QS.id}}')">删除问卷</a></td>
                            </tr>
                            <tr>

                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </ul>

            </div>



        </div>

    </div>




    <script src="../static/js/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="../static/js/bootstrap.min.js"></script>
    <script>
      function warning(){
          window.alert("喵呜~还在完善中");
      }

       // 跳转到修改密码
       function skip(){
           window.location.href='/vim'
       }
       //删除问卷
       function removeQS(QSid){
             axios({
               method: 'post',
               url: '/delete',
               data:{
                   QSid
               }
           }).then(function (response) {
               // axios工具下，服务器真正返回的数据在返回对象的data中
               let res = response.data;
               if (res.code === 200) {
                   window.location.href = '/manager';
               }
           }).catch((err) => {
           });
      
        
       }

        //查看结果
        function findResult(qsId) {
            var url = '/result/?id=' + qsId; //SQ1/?id=qsId
            window.location.href = url;
        }
        //退出系统
        function logout() {
            axios({
                method: 'post',
                url: '/logout'
            }).then(function (response) {
                // axios工具下，服务器真正返回的数据在返回对象的data中
                let res = response.data;
                if (res.code === 200) {
                    window.location.href = '/admin';
                }
            }).catch((err) => {

            });
        }
    </script>
</body>

</html>